<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>个人中心</title>
    <link rel="stylesheet" href="../css/personal_center_sendResumeMsg.css">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="shortcut icon" href="../img/title/招聘求职.png" type="image/x-icon">
	<style>
		.el-table .warning-row {
			background: oldlace;
		}

		.el-table .success-row {
			background: #f0f9eb;
		}

		.el-table .error-row {
			background: #ffd3d3;
		}
	</style>
</head>
<body>
    <div id="app">
		<div class="header">
			<div class="header_left">
				<img src="../img/main/招聘会.png">
				<a href="./main.html">&nbsp;校园兼职管理</a>
			</div>
			<div class="header_center">
				<ul>
					<li><a href="./main.html">主页</a></li>
					<li><a href="./work_list.html">职位</a></li>
					<li><a href="./news.html">校园新闻</a></li>
				</ul>
			</div>
			<div class="header_right">
				<el-button @click="loginBtn" type="success" icon="el-icon-user-solid">登录</el-button>
				<el-button @click="registerBtn" type="success" icon="el-icon-takeaway-box">注册</el-button>
			</div>
		</div>
		<div class="section">
			<div class="section_1">个人中心</div>
			<div class="section_2">首页 > 个人中心 > 已投简历</div>
		</div>
		<div class="content">
			<div class="content_pagecking">
				<div class="content_left">
					<div class="content_left_top">
						<div class="block"><el-avatar :size="80" :src="userMsgList.user_image"></el-avatar></div>
					</div>
					<div class="content_left_bottom">
						<div class="content_left_bottom_item">
							<el-button @click="btn1" type="primary" plain style="width: 90%;height: 100%;" icon="el-icon-s-order">个人信息</el-button>
						</div>
						<div class="content_left_bottom_item">
							<el-button @click="btn2" type="primary" plain style="width: 90%;height: 100%;" icon="el-icon-user-solid">修改密码</el-button>
						</div>
						<div class="content_left_bottom_item">
							<el-button @click="btn3" type="primary" style="width: 90%;height: 100%;" icon="el-icon-s-custom">投递过的岗位</el-button>
						</div>
						<div class="content_left_bottom_item">
							<el-button @click="btn4" type="primary" plain  style="width: 90%;height: 100%;" icon="el-icon-s-tools">退出登录</el-button>
						</div>
					</div>
				</div>
				<div class="content_right">
					    <el-table
								:row-class-name="tableRowClassName"
					      :data="tableList"
					      height="250"
						  :cell-style="rowStyle"
					      border
					      style="width: 100%;">
						  <el-table-column
							align="center"
							type=index
							prop="deliveredLibrary.id"
						    label="序号"
						    width="50">
						  </el-table-column>
					      <el-table-column
							align="center"
					        prop="job.job_name"
					        label="职位名称"
					        width="110">
					      </el-table-column>
					      <el-table-column
							align="center"
					        prop="job.job_address"
					        label="地区"
					        width="60">
					      </el-table-column>
						  <el-table-column
							align="center"
						    prop="jobJoin.company"
						    label="公司"
						    width="150">
						  </el-table-column>
						  <el-table-column
							align="center"
						    prop="jobJoin.principal"
						    label="联系人"
						    width="80">
						  </el-table-column>
						  <el-table-column
							align="center"
						    prop="job.job_price"
						    label="薪资"
						    width="110">
						  </el-table-column>
					      <el-table-column
							align="center"
					        prop="deliveredLibrary.audit_status"
					        label="简历状态"
							width="80">
					      </el-table-column>
						  <el-table-column
						  	align="center"
						    label="操作">
								<template slot-scope="scope">
									<el-button @click="clickrow(scope.row)" slot="reference">撤回/删除</el-button>
								</template>
						  </el-table-column>
					    </el-table>
				</div>
			</div>
		</div>
    </div>
</body>
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="../js/jquery-3.6.1.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script src="../js/after_landing.js"></script>
<script>
    const vm = new Vue({
        el : '#app',
        data(){
            return {
				userMsgList: [],
				tableList : []
            }
        },
        async created(){
			let username = getCookie("cookie_username")
			if (username !== null && username.length > 0) {
				await axios.get('/users/' + username).then((resp) => {
					this.userMsgList = resp.data.data
					$('.header_center ul').append(
						`<li><a href="./personal_resume.html">简历</a></li>`)
					$('.header_center ul').append(`<li><a style="color: lawngreen;" href="./personal_center.html">个人中心</a></li>`)
					$('.header_right').empty()
					let url = this.userMsgList.user_image
					$(".header_right").append(
						`<img style="width: 7%;margin-right: 5px" src="${url}">${username}`);
					$(".header_right").append(
						`<a style="text-decoration: none;color: #77838e;margin-left: 5px" href="/logins/logout">注销</a>`
					);
				})
				await this.getAll();
			} else {
				// document.location.href = "login.html"
			}
        },
        methods:{
			getAll(){
				axios.get('/users/getUserSendResumeMsgById/'+this.userMsgList.id).then((resp)=>{
					this.tableList = resp.data.data
				})
			},
			tableRowClassName({row, rowIndex}) {
				if (row.deliveredLibrary.audit_status === '已入职') {
					return 'success-row';
				} else if (row.deliveredLibrary.audit_status === '沟通中') {
					return 'warning-row';
				} else if (row.deliveredLibrary.audit_status === '已拒绝'){
					return  'error-row'
				}
				return '';
			},
			clickrow(row){
				let idRow = row.deliveredLibrary.id
				this.$confirm("此操作永久删除当前信息，是否继续？","提示",{type:"info"}).then(()=>{
					console.log(idRow)
					axios.delete("/dls/deleteResume/"+idRow).then((res)=>{
						if(res.data.data){
							this.$message.success("删除成功");
						}else{
							this.$message.error("数据同步失败，自动刷新");
						}
					}).finally(()=>{
						//2.重新加载数据
						this.getAll();
					});
				}).catch(()=>{
					this.$message({
						message: "取消操作",
						showClose: true,
					})
				});
			},
			rowStyle() {
			      return "text-align:center";
			},
            loginBtn(){
            	window.location.replace("/pages/login.html");
            },
            registerBtn() {
            	document.location.href = "register.html"
            },
			btn1(){
				document.location.href = "personal_center.html"
			},
			btn2(){
				document.location.href = "personal_center_resetPwd.html"
			},
			btn3(){
				document.location.href = "personal_center_sendResumeMsg.html"
			},
			btn4(){
				document.location.href = "/logins/logout";
			},
			handleCurrentChange(val) {
				// //修改页码值为当前选中的页码值
				// this.pagination.currentPage = val;
				// //执行查询
				// this.getAll();
			},
        }
    })
</script>
</html>